Every boxplot means a monitoring point (Ponto de monitoramento (or PM) in portuguese). My goal here is to analyze the evolution between decades of each water quality parameter that compounds the Water Quality Index (WQI).
The river flows in the east-west direction as shown in the image below.
The logic behind the sorting in the boxplots is because of 2 main reasons:
Some features that I want to add: - If the parameter is x, then use x’s classes (with its own classes background color plotted) - Define the timescale, should act just like a filter
# plan_wide_19902020 %>%
# filter(ANO_COLETA > "1990" &
# ANO_COLETA <= "2000")87398500, 87398980, 87398900, 87398950, 87405500, 87406900, 87409900
~facet.gridNamon tá com com casa decimal "," e
ptot tá com "."| 1990-2000 | 2000-2010 | 2010-2020 |
|---|---|---|
| 1990-2000 | 2000-2010 | 2010-2020 |
# install.packages(tidyverse)# library(ggpubr)
pacman::p_load(readr, rmarkdown, readxl, janitor,
pillar, dplyr, tidyverse,
# gapminder,
knitr, kableExtra, see,
gridExtra, #modelsummary,
gtsummary, ggplot2,
ggbeeswarm, GGally, ggtext, cowplot,
report)
# pacman::p_load(tibbletime)
# cite_packages()knitr::knit_hooks$set(time_it = local({
now <- NULL
function(before, options) {
if (before) {
# record the current time before each chunk
now <<- Sys.time()
} else {
# calculate the time difference after a chunk
res <- difftime(Sys.time(), now)
# return a character string to show the time
paste("Time for this code chunk to run:", res)
}
}
}))
knitr::opts_chunk$set(time_it = TRUE)# version$version.string
# citation(package = "tidyverse")Time for this code chunk to run: 0.00306510925292969
## Rows: 1,179
## Columns: 53
## $ CODIGO <chr> "87398950", "87398900", "87405500", "87398950", "8…
## $ MUNICIPIO <chr> "GRAVATAI - RS", "GRAVATAI - RS", "CACHOEIRINHA - …
## $ ENDERECO <chr> "A PE NO TREVO, NA PONTE VELHA OU DE BARCO VINDO D…
## $ COORD_GEO_LAT_GRAU <dbl> -51.00064, -50.93414, -51.11733, -51.00064, -50.93…
## $ COORD_GEO_LONG_GRAU <dbl> -29.95055, -29.95075, -29.95055, -29.95055, -29.95…
## $ Altitude <dbl> 7, 6, 6, 7, 6, 7, 9, 9, 6, 6, 6, 6, 7, 6, 7, 6, 13…
## $ RECURSO_HIDRICO <chr> "RIO GRAVATAI", "RIO GRAVATAI", "RIO GRAVATAI", "R…
## $ DATA_COLETA <date> 1994-12-08, 1994-02-03, 1994-02-03, 1993-10-06, 1…
## $ ANO_COLETA <dbl> 1994, 1994, 1994, 1993, 1994, 1995, 1994, 1995, 19…
## $ Alcalinidade <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ Condutividade <dbl> 90.0, 47.0, 147.0, 43.0, NA, 47.0, 70.0, 60.6, 72.…
## $ DBO <dbl> 5, 5, 11, 3, 3, 2, 4, 3, 4, 2, 5, 3, 1, 1, 5, 2, 2…
## $ IQA_DBO <dbl> 53.97, 53.97, 29.03, 69.06, 69.06, 78.12, 61.05, 6…
## $ DQO <dbl> 26, 47, 34, 37, 54, 23, 35, 25, 28, 40, 21, 35, 21…
## $ E_coli <dbl> 4.0, 40.0, 12.8, 10.4, 32.0, 16.8, 40.0, 6.4, 10.4…
## $ fosfato_orto <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ fosforo_total <dbl> 0.1130, 0.0883, 0.3530, 0.0908, 0.1180, 0.0326, 0.…
## $ IQA_Ptot <dbl> 72.73, 77.95, 38.26, 77.41, 71.71, 91.16, 63.37, 6…
## $ Nitrato <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ Nitrito <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ nitro_organico <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ nitro_amon <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ nitro_kjeldahl <dbl> 1.42, 1.61, 6.62, 0.79, 1.45, 0.76, 1.23, 1.37, 2.…
## $ nitro_total <dbl> 1.42, 1.61, 6.62, 0.79, 1.45, 0.76, 1.23, 1.37, 2.…
## $ IQA_NitroTot <dbl> 89.02, 87.64, 59.33, 93.74, 88.80, 93.97, 90.41, 8…
## $ oxigenio_dissolvido <dbl> 6.5, 8.7, 5.3, 7.8, 7.6, 8.5, 7.3, 6.9, 6.7, 6.3, …
## $ sat_OD <dbl> 78.162, 116.280, 70.837, 85.270, 96.442, 85.565, 7…
## $ IQA_OD <dbl> 84.58, 90.92, 76.25, 89.67, 97.53, 89.88, 79.57, 7…
## $ pH <dbl> 6.9, 6.8, 6.6, 6.4, 6.9, 6.7, 6.6, 6.7, 6.3, 7.1, …
## $ IQA_pH <dbl> 89.76, 87.72, 82.86, 76.96, 89.76, 85.42, 82.86, 8…
## $ SDT <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ SST <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ temp_agua <dbl> 25.0, 31.0, 31.0, 20.0, 28.0, 16.0, 16.0, 16.0, 18…
## $ temp_ar <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ transparencia_agua <dbl> NA, 40.0, 30.0, NA, NA, NA, 50.0, 20.0, 40.0, 20.0…
## $ turbidez <dbl> 20.0, 20.0, 8.5, 23.0, 19.0, 17.0, 12.0, 22.0, 17.…
## $ IQA_Turb <dbl> 61.87, 61.87, 80.20, 58.73, 63.07, 65.69, 73.57, 5…
## $ vazao_rio <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ Vazao <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ coliformes_termo <dbl> 5, 50, 16, 13, 40, 21, 50, 8, 13, 23, 700, 16, 8, …
## $ IQA_coli <dbl> 76.58, 47.21, 60.44, 63.04, 49.66, 57.12, 47.21, 6…
## $ solidos_totais <dbl> 121, 112, 160, 93, 127, 75, 80, 201, 84, 123, 78, …
## $ IQA_Sól_Tot <dbl> 83.91, 84.69, 79.40, 85.78, 83.28, 86.08, 86.07, 7…
## $ `IQA_^OD` <dbl> 2.126, 2.153, 2.089, 2.148, 2.178, 2.148, 2.104, 2…
## $ `IQA_^temp_agua` <dbl> 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.…
## $ `IQA_^coli` <dbl> 1.917, 1.783, 1.850, 1.862, 1.796, 1.835, 1.783, 1…
## $ `IQA_^pH` <dbl> 1.715, 1.711, 1.699, 1.684, 1.715, 1.705, 1.699, 1…
## $ `IQA_^DBO` <dbl> 1.175, 1.175, 1.271, 1.116, 1.116, 1.072, 1.149, 1…
## $ `IQA_^NitroTot` <dbl> 1.567, 1.564, 1.504, 1.575, 1.566, 1.575, 1.569, 1…
## $ `IQA_^Ptot` <dbl> 1.535, 1.546, 1.440, 1.545, 1.533, 1.570, 1.514, 1…
## $ `IQA_^Turb` <dbl> 1.391, 1.391, 1.420, 1.385, 1.393, 1.398, 1.410, 1…
## $ `IQA_^Sól_Tot` <dbl> 1.425, 1.426, 1.419, 1.428, 1.424, 1.428, 1.428, 1…
## $ IQA <dbl> 61.876, 58.452, 57.556, 57.129, 56.405, 56.189, 55…
Time for this code chunk to run: 0.613819122314453
Time for this code chunk to run: 0.381842136383057
Como há dados faltantes, no cálculo entre o produto das colunas, o R
acaba interpretando como se fosse zero, mas na verdade é
NA.
plan_wide_19902020 <- plan_wide_19902020 %>%
mutate(IQA = ifelse(IQA == 0, NA, IQA))
parametros_IQA <- plan_wide_19902020 %>%
select(CODIGO,
pH,
DBO,
E_coli,
nitro_amon,
nitro_kjeldahl,
nitro_total,
fosforo_total,
temp_agua,
turbidez,
solidos_totais,
oxigenio_dissolvido,
Condutividade,
ANO_COLETA)
write.csv(parametros_IQA,
"./parametros_IQA.csv",
row.names = FALSE)
plan_wide_19902020 %>%
select(starts_with("IQA_^")) %>%
mutate(
TESTANDOIQA = prod()
)## # A tibble: 1,179 × 10
## `IQA_^OD` IQA_^temp…¹ IQA_^…² IQA_^…³ IQA_^…⁴ IQA_^…⁵ IQA_^…⁶ IQA_^…⁷ IQA_^…⁸
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2.13 1.58 1.92 1.72 1.18 1.57 1.54 1.39 1.42
## 2 2.15 1.58 1.78 1.71 1.18 1.56 1.55 1.39 1.43
## 3 2.09 1.58 1.85 1.70 1.27 1.50 1.44 1.42 1.42
## 4 2.15 1.58 1.86 1.68 1.12 1.58 1.54 1.38 1.43
## 5 2.18 1.58 1.80 1.72 1.12 1.57 1.53 1.39 1.42
## 6 2.15 1.58 1.84 1.70 1.07 1.58 1.57 1.40 1.43
## 7 2.10 1.58 1.78 1.70 1.15 1.57 1.51 1.41 1.43
## 8 2.08 1.58 1.89 1.70 1.12 1.57 1.52 1.39 1.41
## 9 2.09 1.58 1.86 1.68 1.15 1.56 1.49 1.40 1.43
## 10 2.13 1.58 1.83 1.72 1.07 1.57 1.55 1.38 1.42
## # … with 1,169 more rows, 1 more variable: TESTANDOIQA <dbl>, and abbreviated
## # variable names ¹`IQA_^temp_agua`, ²`IQA_^coli`, ³`IQA_^pH`, ⁴`IQA_^DBO`,
## # ⁵`IQA_^NitroTot`, ⁶`IQA_^Ptot`, ⁷`IQA_^Turb`, ⁸`IQA_^Sól_Tot`
# library(performance)
# modelo <- plan_wide_19902020 %>%
# select(CODIGO, oxigenio_dissolvido, periodo) %>%
# group_by(CODIGO, periodo) %>%
# lm() %>%
# performance::check_distribution()
# # lm()
#
# check_model(modelo)
# performance::check_autocorrelation(modelo)Time for this code chunk to run: 0.269666910171509
Time for this code chunk to run: 0.00218701362609863
Time for this code chunk to run: 0.00304198265075684
theme_grafs <- function(bg = "white",
coloracao_letra = "black") {
theme(
plot.title =
element_text(
hjust = 0.5,
color = coloracao_letra,
size = 19),
axis.title.x =
# element_text(
# color = coloracao_letra,
# size = 15,
# angle = 0,),
element_blank(),
axis.title.y = element_text(
color = coloracao_letra,
size = 15,
angle = 90),
axis.text.x = element_text(
color = coloracao_letra,
size = 17),
axis.text.y = element_text(
color = coloracao_letra,
size = 17,
angle = 0),
strip.background = element_rect(fill = bg,
linetype = 1,
size = 0.5,
color = "black"),
strip.text = element_text(size = 17),
panel.background = element_rect(fill = bg),
plot.background = element_rect(fill = bg),
plot.margin = margin(l = 5, r = 10,
b = 5, t = 5)
)
}Time for this code chunk to run: 0.00351190567016602
Time for this code chunk to run: 0.00654387474060059
Time for this code chunk to run: 0.00725698471069336
f <- function(x) {
r <- quantile(x, probs = c(0.05, 0.20, 0.50, 0.80, 0.95))
names(r) <- c("ymin", "lower", "middle", "upper", "ymax")
return(r)
}Time for this code chunk to run: 0.00352811813354492
Time for this code
chunk to run: 1.26934480667114
Time for this code
chunk to run: 2.02952980995178
Time
for this code chunk to run: 0.843261957168579
Time
for this code chunk to run: 0.706562042236328
grid.arrange(od_p1, od_p2, od_p3, ncol = 3)Time for this code
chunk to run: 2.08029103279114
# ggsave("od.png",
# units = c("px"),
# width = 4500,
# height = 2993,
# plot = od,
# path = "./graficos",
# dpi = 300,
# type = "cairo")
ggsave("od_p1.png",
plot = od_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("od_p2.png",
plot = od_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("od_p3.png",
plot = od_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("od_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(od_p1, od_p2, od_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time for
this code chunk to run: 6.05964016914368
Time for this code chunk to run: 0.00866484642028809
Time
for this code chunk to run: 0.690712928771973
Time
for this code chunk to run: 0.847044944763184
Time
for this code chunk to run: 1.04315996170044
grid.arrange(iqaod_p1, iqaod_p2, iqaod_p3, ncol = 3)Time
for this code chunk to run: 2.40081405639648
## # A tibble: 7 × 8
## par PM1 PM2 PM3 PM4 PM5 PM6 PM7
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 max 10.8 10.5 10.3 12.1 19.9 10.2 11.1
## 2 q3 7.3 8 7.1 8.2 6 5 5.65
## 3 median 6.4 6.9 5.95 6.3 4.2 2.6 2.9
## 4 mean 5.99 6.78 5.98 7.01 4.22 2.98 3.60
## 5 q1 4.9 5.6 4.4 6 1.9 0.25 1.4
## 6 min 0.8 2 2.5 4.2 0.1 0.1 0.1
## 7 n 101 101 68 30 97 32 65
## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.4 3.5 4.9 5.01 6.65 10.9
## 2 87398900 1.9 4 5.5 5.33 6.6 12
## 3 87398950 1.7 3.2 5.3 5.06 6.18 8.9
## 4 87398980 1.2 3.8 5.6 5.38 6.6 9.2
## 5 87405500 0.2 1.4 2.55 3.28 4 14.2
## 6 87406900 0 1.1 1.9 2.59 3.15 16
## 7 87409900 0 0.7 2.3 3.12 3.7 10.6
## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.38 3.11 4.41 4.57 6.2 12.4
## 2 87398900 3.52 5.25 5.96 6.61 7.3 13.8
## 3 87398950 1.62 3.68 4.92 5.28 6.64 11.9
## 4 87398980 3.37 5.5 6.17 6.48 7.14 13.1
## 5 87405500 0.2 1.3 2.53 2.83 3.66 9.8
## 6 87406900 0.1 0.865 2.4 2.43 3.05 9.1
## 7 87409900 0.1 0.92 2.03 2.43 3.5 8.1
Time for this code chunk to run: 0.406455039978027
(dbo <- ggplot(plan_wide_19902020,
aes(x = CODIGO,
y = DBO))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=10,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=5,
ymax=10,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3,
ymax=5,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Demanda Bioquímica de Oxigênio no período 1990-2020",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(1,100),
trans = "log10")+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 60 rows containing non-finite values (`stat_boxplot()`).
## Removed 60 rows containing non-finite values (`stat_boxplot()`).
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 22 rows containing missing values.
## Warning: Removed 30 rows containing missing values.
## Warning: Removed 8 rows containing missing values.
Time for
this code chunk to run: 2.04859709739685
Time
for this code chunk to run: 1.10499286651611
Time
for this code chunk to run: 1.10075092315674
Time
for this code chunk to run: 1.00755405426025
Time
for this code chunk to run: 1.23249101638794
Time
for this code chunk to run: 0.880059957504272
Time
for this code chunk to run: 0.773524045944214
grid.arrange(dbo_p1, dbo_p2, dbo_p3, ncol = 3)Time
for this code chunk to run: 2.46709489822388
(sum_dbo_p1 <- plan_wide_19902020 %>%
select(CODIGO, DBO, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(DBO,
na.rm = TRUE),
q1 =
quantile(DBO, 0.25,
na.rm = TRUE),
median =
median(DBO,
na.rm = TRUE),
mean =
mean(DBO,
na.rm= TRUE),
q3 =
quantile(DBO, 0.75,
na.rm = TRUE),
max =
max(DBO,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 1 1 2 1.86 2 13
## 2 87398900 1 1 1 1.52 2 6
## 3 87398950 1 1 1 1.66 2 6
## 4 87398980 1 1 1 1.13 1 2
## 5 87405500 1 2 3 5.37 5 64
## 6 87406900 1 4 5 9 11 26
## 7 87409900 2 3 4 6.97 9.5 31
(sum_dbo_p2 <- plan_wide_19902020 %>%
select(CODIGO, DBO, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(DBO,
na.rm = TRUE),
q1 =
quantile(DBO, 0.25,
na.rm = TRUE),
median =
median(DBO,
na.rm = TRUE),
mean =
mean(DBO,
na.rm= TRUE),
q3 =
quantile(DBO, 0.75,
na.rm = TRUE),
max =
max(DBO,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 1 1 1 1.58 2 5
## 2 87398900 1 1 1 1.40 2 5
## 3 87398950 1 1 1 1.66 2 5
## 4 87398980 1 1 1 1.30 1 5
## 5 87405500 1 2 4 4.67 6.5 14
## 6 87406900 1 3 5 6.53 8 28
## 7 87409900 1 3 6 6.31 9 15
(sum_dbo_p3 <- plan_wide_19902020 %>%
select(CODIGO, DBO, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(DBO,
na.rm = TRUE),
q1 =
quantile(DBO, 0.25,
na.rm = TRUE),
median =
median(DBO,
na.rm = TRUE),
mean =
mean(DBO,
na.rm= TRUE),
q3 =
quantile(DBO, 0.75,
na.rm = TRUE),
max =
max(DBO,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 1 1 1.5 2.15 3 7
## 2 87398900 1 1 1 1.51 2 5
## 3 87398950 1 1 2 2.65 2 18
## 4 87398980 1 1 1 1.32 2 2
## 5 87405500 1 3 4 5.28 6.25 21
## 6 87406900 1 3 5 6.58 10 24
## 7 87409900 1 3 4.5 6.18 8 18
Time for this code chunk to run: 0.265676021575928
ggsave("dbo.png",
units = c("px"),
width = 4500,
height = 2993,
plot = dbo,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("dbo_p1.png",
plot = dbo_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("dbo_p2.png",
plot = dbo_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("dbo_p3.png",
plot = dbo_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("dbo_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(dbo_p1, dbo_p2, dbo_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 8.27701210975647
(ptot <- ggplot(plan_wide_19902020,
aes(CODIGO,
fosforo_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Fósforo total no período 1990-2020",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$fosforo_total, na.rm = TRUE),
max(plan_wide_19902020$fosforo_total), na.rm = TRUE),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " ")
)+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 134 rows containing non-finite values (`stat_boxplot()`).
## Removed 134 rows containing non-finite values (`stat_boxplot()`).
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 47 rows containing missing values.
## Warning: Removed 31 rows containing missing values.
## Warning: Removed 56 rows containing missing values.
Time for this code chunk to
run: 1.74387812614441
(ptot_p1<-ggplot(plan_wide_19902020%>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
fosforo_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Fósforo total no período 1990-2000",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$fosforo_total, na.rm = TRUE),
max(plan_wide_19902020$fosforo_total), na.rm = TRUE),
trans = "log10")+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 1.01013493537903
(ptot_p2 <- ggplot(plan_wide_19902020%>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
fosforo_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Fósforo total no período 2000-2010",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$fosforo_total, na.rm = TRUE),
max(plan_wide_19902020$fosforo_total), na.rm = TRUE),
trans = "log10")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.853737115859985
(ptot_p3 <- ggplot(plan_wide_19902020%>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
fosforo_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Fósforo total no período 2010-2020",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$fosforo_total, na.rm = TRUE),
max(plan_wide_19902020$fosforo_total), na.rm = TRUE),
trans = "log10")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.713698148727417
grid.arrange(ptot_p1, ptot_p2, ptot_p3, ncol = 3)Time
for this code chunk to run: 2.00980401039124
(sum_ptot_p1 <- plan_wide_19902020 %>%
select(CODIGO, fosforo_total, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(fosforo_total, na.rm = TRUE),
q1 =
quantile(fosforo_total, 0.25, na.rm = TRUE),
median =
median(fosforo_total, na.rm = TRUE),
mean =
mean(fosforo_total, na.rm= TRUE),
q3 =
quantile(fosforo_total, 0.75, na.rm = TRUE),
max =
max(fosforo_total, na.rm = TRUE)))## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.0097 0.0593 0.0881 0.123 0.14 0.863
## 2 87398900 0.0023 0.0468 0.0678 0.0747 0.0883 0.247
## 3 87398950 0.0202 0.0544 0.0737 0.0751 0.0904 0.179
## 4 87398980 0.01 0.0254 0.0547 0.0708 0.114 0.189
## 5 87405500 0.017 0.171 0.281 0.417 0.492 2.32
## 6 87406900 0.156 0.270 0.508 0.785 1.07 2.79
## 7 87409900 0.107 0.258 0.384 0.489 0.712 1.53
(sum_ptot_p2 <- plan_wide_19902020 %>%
select(CODIGO, fosforo_total, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(fosforo_total, na.rm = TRUE),
q1 =
quantile(fosforo_total, 0.25, na.rm = TRUE),
median =
median(fosforo_total, na.rm = TRUE),
mean =
mean(fosforo_total, na.rm= TRUE),
q3 =
quantile(fosforo_total, 0.75, na.rm = TRUE),
max =
max(fosforo_total, na.rm = TRUE)))## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.025 0.094 0.131 0.148 0.16 0.637
## 2 87398900 0.015 0.0764 0.104 0.140 0.164 0.646
## 3 87398950 0.036 0.116 0.171 0.180 0.207 0.485
## 4 87398980 0.0115 0.052 0.076 0.101 0.103 1
## 5 87405500 0.046 0.261 0.406 0.547 0.681 1.98
## 6 87406900 0.056 0.338 0.599 0.752 0.967 3.49
## 7 87409900 0.043 0.325 0.624 0.677 0.989 1.57
(sum_ptot_p3 <- plan_wide_19902020 %>%
select(CODIGO, fosforo_total, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(fosforo_total, na.rm = TRUE),
q1 =
quantile(fosforo_total, 0.25, na.rm = TRUE),
median =
median(fosforo_total, na.rm = TRUE),
mean =
mean(fosforo_total, na.rm= TRUE),
q3 =
quantile(fosforo_total, 0.75, na.rm = TRUE),
max =
max(fosforo_total, na.rm = TRUE)))## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.061 0.118 0.163 0.166 0.186 0.381
## 2 87398900 0.057 0.0935 0.130 0.163 0.168 0.444
## 3 87398950 0.07 0.132 0.156 0.292 0.221 3.11
## 4 87398980 0.019 0.0625 0.106 0.144 0.170 0.59
## 5 87405500 0.013 0.187 0.332 0.361 0.45 0.803
## 6 87406900 0.089 0.254 0.364 0.448 0.560 1.26
## 7 87409900 0.203 0.259 0.369 0.488 0.564 1.7
Time for this code chunk to run: 0.241081953048706
ggsave("ptot.png",
units = c("px"),
width = 4500,
height = 2993,
plot = ptot,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ptot_p1.png",
plot = ptot_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ptot_p2.png",
plot = ptot_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ptot_p3.png",
plot = ptot_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ptot_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(ptot_p1, ptot_p2, ptot_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 7.53798890113831
ecoli__class <- function() {
list(annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb") #classe 1
)
}
(ecoli <- ggplot(plan_wide_19902020,
aes(CODIGO,
E_coli))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "*Escherichia coli* no período 1990-2020",
x="Estação",
y="NMP/100mL")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
# n.breaks = 9,
n.breaks = 6,
limits = c(min(plan_wide_19902020$E_coli, na.rm = TRUE),
max(plan_wide_19902020$E_coli, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()+
theme(
axis.text.y = element_text(
angle = 90,
# size=15,
# face=2
),
plot.title =
element_markdown(
hjust = 0.5,
color = "black",
size = 19)
)
)Time for this
code chunk to run: 1.69103384017944
(ecoli_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
E_coli))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Escherichia coli no período 1990-2000",
x="Estação",
y="NMP/100mL")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$E_coli, na.rm = TRUE),
max(plan_wide_19902020$E_coli, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.863179206848145
(ecoli_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
E_coli))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Escherichia coli no período 2000-2010",
x="Estação",
y="NMP/100mL")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$E_coli, na.rm = TRUE),
max(plan_wide_19902020$E_coli, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.85694408416748
(ecoli_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
E_coli))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Escherichia coli no período 2010-2020",
x="Estação",
y="NMP/100mL")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$E_coli, na.rm = TRUE),
max(plan_wide_19902020$E_coli, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.78161883354187
grid.arrange(ecoli_p1, ecoli_p2, ecoli_p3, ncol = 3)Time
for this code chunk to run: 2.40403604507446
(sum_ecoli_p1 <- plan_wide_19902020 %>%
select(CODIGO, E_coli, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(E_coli,
na.rm = TRUE),
q1 =
quantile(E_coli, 0.25,
na.rm = TRUE),
median =
median(E_coli,
na.rm = TRUE),
mean =
mean(E_coli,
na.rm= TRUE),
q3 =
quantile(E_coli, 0.75,
na.rm = TRUE),
max =
max(E_coli,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 32 136 240 854. 720 19200
## 2 87398900 16 68 160 548. 480 7760
## 3 87398950 2.4 12.8 268 4039. 10000 28000
## 4 87398980 4 160 243. 2907. 446 25600
## 5 87405500 1.6 12.8 24 545. 128 18400
## 6 87406900 13.6 61.6 192 718. 414 12800
## 7 87409900 2.4 12.8 64 97.7 128 720
(sum_ecoli_p2 <- plan_wide_19902020 %>%
select(CODIGO, E_coli, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(E_coli,
na.rm = TRUE),
q1 =
quantile(E_coli, 0.25,
na.rm = TRUE),
median =
median(E_coli,
na.rm = TRUE),
mean =
mean(E_coli,
na.rm= TRUE),
q3 =
quantile(E_coli, 0.75,
na.rm = TRUE),
max =
max(E_coli,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 21.6 91 150 1335. 308 27200
## 2 87398900 11 70 133. 444. 414. 2600
## 3 87398950 20 400 720 935. 1120 5500
## 4 87398980 24 110. 195 410. 289. 8800
## 5 87405500 4.7 162 2400 25445. 12950 490000
## 6 87406900 8 172 12800 66370. 62300 650000
## 7 87409900 16 7355. 35500 72440. 68750 460000
(sum_ecoli_p3 <- plan_wide_19902020 %>%
select(CODIGO, E_coli, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(E_coli,
na.rm = TRUE),
q1 =
quantile(E_coli, 0.25,
na.rm = TRUE),
median =
median(E_coli,
na.rm = TRUE),
mean =
mean(E_coli,
na.rm= TRUE),
q3 =
quantile(E_coli, 0.75,
na.rm = TRUE),
max =
max(E_coli,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 90 155. 260 409. 451 2420
## 2 87398900 10 52.8 107 245. 313 1553.
## 3 87398950 108. 250 487 1424. 1553. 10462
## 4 87398980 40.8 140. 242. 529. 738. 2400
## 5 87405500 632 8965 19232. 109992. 70750 1400000
## 6 87406900 1440 23100 34500 230828. 140500 3400000
## 7 87409900 2000 20100 38400 83128. 83680 345000
Time for this code chunk to run: 0.287384986877441
ggsave("ecoli.png",
plot = ecoli,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ecoli_p1.png",
plot = ecoli_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ecoli_p2.png",
plot = ecoli_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ecoli_p3.png",
plot = ecoli_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ecoli_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(ecoli_p1, ecoli_p2, ecoli_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 9.12989902496338
(namon <- ggplot(plan_wide_19902020,
aes(CODIGO,
nitro_amon))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Nitrogênio amoniacal no período 1990-2020",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$nitro_total, na.rm = TRUE),
max(plan_wide_19902020$nitro_total, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for this code
chunk to run: 1.39606714248657
periodo_inicial <- as.Date("1990-01-01", "%Y-%m-%d")
periodo_final <- as.Date("2021-01-01", "%Y-%m-%d")
(nitro_line <-
plan_wide_19902020 %>%
filter(ANO_COLETA > "1990" &
ANO_COLETA <= "2020") %>%
dplyr::select(CODIGO, nitro_amon, DATA_COLETA, periodo) %>%
group_by(CODIGO) %>%
# pivot_wider(
# names_from = CODIGO,
# values_from = nitro_amon,
# id_cols = DATA_COLETA
# ) %>%
ggplot(
aes(x = DATA_COLETA,
y = nitro_amon,
# color = CODIGO
))+
# geom_rect(
# aes(xmin = periodo_inicial,
# xmax = periodo_final,
# ymin = 13.3,
# ymax = Inf,
# alpha= 0.005,
# fill= "#ac5079"),
# show.legend = FALSE)+ #>pior classe
# geom_rect(
# aes(xmin = periodo_inicial,
# xmax = periodo_final,
# ymin= 3.7,
# ymax= 13.3,
# alpha= 0.005,
# fill= "#fcf7ab"),
# show.legend = FALSE)+ #classe 3
# geom_rect(
# aes(xmin = periodo_inicial,
# xmax = periodo_final,
# ymin= 0,
# ymax= 3.7,
# alpha= 0.005,
# fill= "blue"
# # "#8dcdeb"
# ),
# show.legend = FALSE)+ #classe 1
annotate("rect",
xmin= periodo_inicial,
xmax= periodo_final,
ymin=13.3,
ymax=Inf,
alpha= 0.7,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin= periodo_inicial,
xmax= periodo_final,
ymin=3.7,
ymax=13.3,
alpha= 0.7,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin= periodo_inicial,
xmax= periodo_final,
ymin= -Inf,
ymax=3.7,
alpha= 0.7,
fill="#8dcdeb")+ #classe 1
geom_line(
# aes(color = CODIGO),
na.rm = TRUE)+
geom_point(
# aes(color = CODIGO),
na.rm = TRUE)+
scale_x_date(
limits = as.Date(c(
"1990-01-01",
"2021-01-01"
# NA #pode usar NA também
)),
expand = c(0.0, 0.0),
date_breaks = "10 years",
minor_breaks = "5 years",
date_labels = "%Y",
)+
# geom_smooth(
# # aes(color = CODIGO),
# method = "lm",
# # formula = y ~ poly(x, 2),
# # span = 0.2,
# se = TRUE, #se deixar TRUE gera o intervalo de confiança de 95%
# aes(group = 1),
# alpha =.5,
# na.rm = TRUE,
# size = 0.3,
# # fullrange = TRUE,
# # show.legend = TRUE
# )+
# stat_smooth(
# geom = "smooth",
# # span = 0.2,
# se = FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
# # aes(group = 1),
# # alpha =.5,
# na.rm = TRUE,
# # size = 0.3,
# fullrange = TRUE,
# show.legend = TRUE
# )+
facet_wrap(
~CODIGO,
nrow = 4,
)+
theme_bw()
)Time
for this code chunk to run: 1.01748991012573
(namon_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
nitro_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Nitrogênio amoniacal no período 1990-2000",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$nitro_total, na.rm = TRUE),
max(plan_wide_19902020$nitro_total, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.886121034622192
(namon_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
nitro_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Nitrogênio amoniacal no período 2000-2010",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$nitro_total, na.rm = TRUE),
max(plan_wide_19902020$nitro_total, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.788445949554443
(namon_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
nitro_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Nitrogênio amoniacal no período 2010-2020",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$nitro_total, na.rm = TRUE),
max(plan_wide_19902020$nitro_total, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.731498003005981
grid.arrange(namon_p1, namon_p2, namon_p3, ncol = 3)Time
for this code chunk to run: 2.17817807197571
(sum_namon_p1 <- plan_wide_19902020 %>%
select(CODIGO, nitro_total, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(nitro_total,
na.rm = TRUE),
q1 =
quantile(nitro_total, 0.25,
na.rm = TRUE),
median =
median(nitro_total,
na.rm = TRUE),
mean =
mean(nitro_total,
na.rm= TRUE),
q3 =
quantile(nitro_total, 0.75,
na.rm = TRUE),
max =
max(nitro_total,
na.rm = TRUE),
n =
length(nitro_total)
)
)## # A tibble: 7 × 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 0.44 0.842 1.00 1.22 1.34 3.81 101
## 2 87398900 0.22 0.82 1 1.09 1.25 4.86 101
## 3 87398950 0.51 0.83 1.02 1.06 1.19 2.16 68
## 4 87398980 0.549 0.68 0.755 0.872 1.01 1.85 30
## 5 87405500 0.51 1.53 2.94 5.27 6.77 21.6 97
## 6 87406900 1.34 2.60 4.56 7.58 11.2 29.1 32
## 7 87409900 0.5 1.98 4.29 5.18 7.01 19.6 65
(sum_namon_p2 <- plan_wide_19902020 %>%
select(CODIGO, nitro_total, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(nitro_total,
na.rm = TRUE),
q1 =
quantile(nitro_total, 0.25,
na.rm = TRUE),
median =
median(nitro_total,
na.rm = TRUE),
mean =
mean(nitro_total,
na.rm= TRUE),
q3 =
quantile(nitro_total, 0.75,
na.rm = TRUE),
max =
max(nitro_total,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.18 0.885 0.992 1.80 1.46 23.2
## 2 87398900 0.48 0.894 1.13 1.38 1.57 7.92
## 3 87398950 0.57 1.26 1.45 1.43 1.71 1.98
## 4 87398980 0.19 0.685 0.79 1.05 1.10 5.2
## 5 87405500 0.968 2 3.29 5.45 6.60 21.7
## 6 87406900 0.77 2.4 4.54 7.30 10.2 39.1
## 7 87409900 1.62 2.5 6.97 7.92 10.6 21.5
(sum_namon_p3 <- plan_wide_19902020 %>%
select(CODIGO, nitro_total, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(nitro_total,
na.rm = TRUE),
q1 =
quantile(nitro_total, 0.25,
na.rm = TRUE),
median =
median(nitro_total,
na.rm = TRUE),
mean =
mean(nitro_total,
na.rm= TRUE),
q3 =
quantile(nitro_total, 0.75,
na.rm = TRUE),
max =
max(nitro_total,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.222 0.89 1.11 1.24 1.41 2.56
## 2 87398900 0.095 0.883 1.02 1.29 1.40 4.25
## 3 87398950 0.612 1.04 1.43 1.90 2.06 9.5
## 4 87398980 0.216 0.973 1.12 1.22 1.58 2.32
## 5 87405500 1.12 2.03 3.14 4.50 5.93 22.0
## 6 87406900 1.37 2.40 5.58 6.47 7.58 25
## 7 87409900 1.11 3 6.15 7.29 7.75 36
Time for this code chunk to run: 0.264324188232422
ggsave("namon.png",
units = c("px"),
width = 4500,
height = 2993,
plot = namon,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("namon_p1.png",
plot = namon_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("namon_p2.png",
plot = namon_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("namon_p3.png",
plot = namon_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("namon_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(namon_p1, namon_p2, namon_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 7.46358108520508
(turb <- ggplot(plan_wide_19902020,
aes(CODIGO,
turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Turbidez no período 1990-2020",
x="Estação",
y="UNT")+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.05)),
n.breaks = 8,
limits = c(
# 1,
min(plan_wide_19902020$turbidez, na.rm = TRUE),
# 500
max(plan_wide_19902020$turbidez, na.rm = TRUE)
),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for this code chunk
to run: 1.61757397651672
(turb_line <- plan_wide_19902020 %>%
filter(ANO_COLETA > "1990" &
ANO_COLETA <= "2020") %>%
select(CODIGO, turbidez, DATA_COLETA, periodo) %>%
group_by(CODIGO) %>%
ggplot(
aes(x = DATA_COLETA,
y = turbidez,
color = CODIGO
))+
geom_line(
# aes(color = CODIGO),
na.rm = TRUE)+
geom_point(
# aes(color = CODIGO),
na.rm = TRUE)+
scale_x_date(
limits = as.Date(c(
"1990-01-01",
"2021-01-01"
# NA #pode usar NA também
)),
expand = c(0.0, 0.0),
date_breaks = "10 years",
minor_breaks = "5 years",
date_labels = "%Y",
)+
# geom_smooth(
# # aes(color = CODIGO),
# method = "lm",
# # formula = y ~ poly(x, 2),
# # span = 0.2,
# se = TRUE, #se deixar TRUE gera o intervalo de confiança de 95%
# aes(group = 1),
# alpha =.5,
# na.rm = TRUE,
# size = 0.3,
# # fullrange = TRUE,
# # show.legend = TRUE
# )+
# stat_smooth(
# geom = "smooth",
# # span = 0.2,
# se = FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
# # aes(group = 1),
# # alpha =.5,
# na.rm = TRUE,
# # size = 0.3,
# fullrange = TRUE,
# show.legend = TRUE
# )+
facet_wrap(
~CODIGO,
nrow = 4,
)+
theme_bw()
)Time
for this code chunk to run: 1.30168700218201
(turb_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Turbidez no período 1990-2000",
x="Estação",
y="UNT")+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$turbidez, na.rm = TRUE),
max(plan_wide_19902020$turbidez, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.816999912261963
(turb_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Turbidez no período 2000-2010",
x="Estação",
y="UNT")+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$turbidez, na.rm = TRUE),
max(plan_wide_19902020$turbidez, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.775570154190063
(turb_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Turbidez no período 2010-2020",
x="Estação",
y="UNT")+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$turbidez, na.rm = TRUE),
max(plan_wide_19902020$turbidez, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.809418916702271
grid.arrange(turb_p1, turb_p2, turb_p3, ncol = 3)Time
for this code chunk to run: 2.10943388938904
(sum_turb_p1 <- plan_wide_19902020 %>%
select(CODIGO, turbidez, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(turbidez,
na.rm = TRUE),
q1 =
quantile(turbidez, 0.25,
na.rm = TRUE),
median =
median(turbidez,
na.rm = TRUE),
mean =
mean(turbidez,
na.rm= TRUE),
q3 =
quantile(turbidez, 0.75,
na.rm = TRUE),
max =
max(turbidez,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 6.2 19 34.5 63.5 67 461
## 2 87398900 9 19 49.5 61.5 73.8 460
## 3 87398950 9.6 16 22 33.3 48.8 144
## 4 87398980 16 32.8 43 66.8 90.5 190
## 5 87405500 8.5 23.5 47 47.5 58 159
## 6 87406900 33 54.8 67 77.7 81.5 199
## 7 87409900 5.8 15 25 32.2 48 76
(sum_turb_p2 <- plan_wide_19902020 %>%
select(CODIGO, turbidez, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(turbidez,
na.rm = TRUE),
q1 =
quantile(turbidez, 0.25,
na.rm = TRUE),
median =
median(turbidez,
na.rm = TRUE),
mean =
mean(turbidez,
na.rm= TRUE),
q3 =
quantile(turbidez, 0.75,
na.rm = TRUE),
max =
max(turbidez,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 9 41.2 55.5 71.1 74.2 428
## 2 87398900 39 57 78 107. 116. 475
## 3 87398950 39 47 64 96.5 90 330
## 4 87398980 24 37 50 64.5 87 176
## 5 87405500 32 46 63.5 70.3 76 341
## 6 87406900 35 49 62 69.9 75.5 284
## 7 87409900 40 45 60 70.4 90 151
(sum_turb_p3 <- plan_wide_19902020 %>%
select(CODIGO, turbidez, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(turbidez,
na.rm = TRUE),
q1 =
quantile(turbidez, 0.25,
na.rm = TRUE),
median =
median(turbidez,
na.rm = TRUE),
mean =
mean(turbidez,
na.rm= TRUE),
q3 =
quantile(turbidez, 0.75,
na.rm = TRUE),
max =
max(turbidez,
na.rm = TRUE))
) ## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 8.52 16.4 29 33.3 43 85
## 2 87398900 14.8 39.2 48.3 66.7 73.4 299
## 3 87398950 16 29.9 41 51.6 65 230
## 4 87398980 11 19.4 33.6 39.5 42.2 110.
## 5 87405500 10.0 29.0 41 42.9 54.5 131
## 6 87406900 9.62 23 39 41.2 52 122
## 7 87409900 9.68 22.0 34.0 40.5 47 182.
Time for this code chunk to run: 0.30211615562439
ggsave("turb.png",
units = c("px"),
width = 4500,
height = 2993,
plot = turb,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("turb_p1.png",
plot = turb_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("turb_p2.png",
plot = turb_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("turb_p3.png",
plot = turb_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("turb_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(turb_p1, turb_p2, turb_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 8.77911686897278
(pH <- ggplot(plan_wide_19902020,
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "pH no período 1990-2020",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for this code chunk to
run: 1.95946097373962
(pH_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "pH no período 1990-2000",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.882468938827515
(pH_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "pH no período 2000-2010",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.962517023086548
(pH_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "pH no período 2010-2020",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.870226144790649
grid.arrange(pH_p1, pH_p2, pH_p3, ncol = 3)Time
for this code chunk to run: 2.31190705299377
(sum_pH_p1 <- plan_wide_19902020 %>%
select(CODIGO, pH, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(pH,
na.rm = TRUE),
q1 =
quantile(pH, 0.25,
na.rm = TRUE),
median =
median(pH,
na.rm = TRUE),
mean =
mean(pH,
na.rm= TRUE),
q3 =
quantile(pH, 0.75,
na.rm = TRUE),
max =
max(pH,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 5 6.18 6.59 6.51 6.82 7.9
## 2 87398900 5.2 6 6.3 6.33 6.63 7.9
## 3 87398950 5.4 6.29 6.4 6.49 6.72 8.1
## 4 87398980 5.3 5.93 6.2 6.16 6.3 7.3
## 5 87405500 5 6.3 6.4 6.47 6.7 9.3
## 6 87406900 5.5 6.18 6.45 6.43 6.8 7.3
## 7 87409900 4.5 6.2 6.4 6.44 6.7 7.4
(sum_pH_p2 <- plan_wide_19902020 %>%
select(CODIGO, pH, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(pH,
na.rm = TRUE),
q1 =
quantile(pH, 0.25,
na.rm = TRUE),
median =
median(pH,
na.rm = TRUE),
mean =
mean(pH,
na.rm= TRUE),
q3 =
quantile(pH, 0.75,
na.rm = TRUE),
max =
max(pH,
na.rm = TRUE))
) ## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 5.3 6.3 6.6 6.59 6.88 7.9
## 2 87398900 5.5 6.4 6.65 6.63 6.9 7.5
## 3 87398950 6 6.6 6.8 6.89 7.25 7.6
## 4 87398980 5.8 6.3 6.5 6.63 7 7.5
## 5 87405500 5.2 6.4 6.6 6.68 6.9 8.3
## 6 87406900 5.5 6.4 6.7 6.66 6.9 8.6
## 7 87409900 5.8 6.5 6.8 6.77 7 8.4
(sum_pH_p3 <- plan_wide_19902020 %>%
select(CODIGO, pH, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(pH,
na.rm = TRUE),
q1 =
quantile(pH, 0.25,
na.rm = TRUE),
median =
median(pH,
na.rm = TRUE),
mean =
mean(pH,
na.rm= TRUE),
q3 =
quantile(pH, 0.75,
na.rm = TRUE),
max =
max(pH,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 5.47 6.28 6.42 6.47 6.60 7.3
## 2 87398900 5.68 6.36 6.5 6.57 6.84 7.4
## 3 87398950 5.71 6.28 6.46 6.46 6.68 7
## 4 87398980 5.42 6.10 6.36 6.39 6.6 7.2
## 5 87405500 5.64 6.34 6.5 6.49 6.7 7.01
## 6 87406900 5.6 6.4 6.48 6.51 6.77 7.3
## 7 87409900 5.59 6.46 6.6 6.57 6.76 7.2
Time for this code chunk to run: 0.301358938217163
ggsave("pH.png",
units = c("px"),
width = 4500,
height = 2993,
plot = pH,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("pH_p1.png",
plot = pH_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("pH_p2.png",
plot = pH_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("pH_p3.png",
plot = pH_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("pH_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(pH_p1, pH_p2, pH_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time for
this code chunk to run: 8.6573498249054
(SolTot <- ggplot(plan_wide_19902020,
aes(CODIGO,
solidos_totais))+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 500, ymax = Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Sólidos totais no período 1990-2020",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$solidos_totais, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for this code
chunk to run: 1.62928700447083
(SolTot_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
solidos_totais))+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 500, ymax = Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Sólidos totais no período 1990-2000",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$solidos_totais, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.773993968963623
(SolTot_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
solidos_totais))+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 500, ymax = Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Sólidos totais no período 2000-2010",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$solidos_totais, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.803251028060913
(SolTot_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
solidos_totais))+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 500, ymax = Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Sólidos totais no período 2010-2020",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$solidos_totais, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.676017045974731
grid.arrange(SolTot_p1, SolTot_p2, SolTot_p3, ncol = 3)Time
for this code chunk to run: 2.26647806167603
(sum_SolTot_p1 <- plan_wide_19902020 %>%
select(CODIGO, solidos_totais, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(solidos_totais,
na.rm = TRUE),
q1 =
quantile(solidos_totais, 0.25,
na.rm = TRUE),
median =
median(solidos_totais,
na.rm = TRUE),
mean =
mean(solidos_totais,
na.rm= TRUE),
q3 =
quantile(solidos_totais, 0.75,
na.rm = TRUE),
max =
max(solidos_totais,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 46 84.5 95 122. 120 510
## 2 87398900 18 74.5 97 111. 122. 474
## 3 87398950 10 76.5 91 90.9 106. 155
## 4 87398980 48 63.5 81.5 104. 126. 337
## 5 87405500 70 101 121 133. 151 361
## 6 87406900 89 118 155 165. 210 279
## 7 87409900 20 99.5 122 128. 143 381
(sum_SolTot_p2 <- plan_wide_19902020 %>%
select(CODIGO, solidos_totais, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(solidos_totais,
na.rm = TRUE),
q1 =
quantile(solidos_totais, 0.25,
na.rm = TRUE),
median =
median(solidos_totais,
na.rm = TRUE),
mean =
mean(solidos_totais,
na.rm= TRUE),
q3 =
quantile(solidos_totais, 0.75,
na.rm = TRUE),
max =
max(solidos_totais,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 28 80 100 111. 123. 412
## 2 87398900 42 82 102. 128. 140. 489
## 3 87398950 46 94.2 108. 126. 127. 318
## 4 87398980 40 61 77 85.3 96 228
## 5 87405500 48 102 133 148. 170. 522
## 6 87406900 50 109 134. 154. 170. 670
## 7 87409900 56 112. 156 167. 190. 599
(sum_SolTot_p3 <- plan_wide_19902020 %>%
select(CODIGO, solidos_totais, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(solidos_totais,
na.rm = TRUE),
q1 =
quantile(solidos_totais, 0.25,
na.rm = TRUE),
median =
median(solidos_totais,
na.rm = TRUE),
mean =
mean(solidos_totais,
na.rm= TRUE),
q3 =
quantile(solidos_totais, 0.75,
na.rm = TRUE),
max =
max(solidos_totais,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 61 69 90 82.8 96 101
## 2 87398900 41 77 104 120. 127 308
## 3 87398950 45 93 101 109. 117 221
## 4 87398980 55 62.8 80 79.9 95 109
## 5 87405500 83 89.2 108. 124. 162. 195
## 6 87406900 50 106 117 135. 163 246
## 7 87409900 75 103 115 131. 145 251
Time for this code chunk to run: 0.26396107673645
ggsave("SolTot.png",
units = c("px"),
width = 4500,
height = 2993,
plot = SolTot,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("SolTot_p1.png",
plot = SolTot_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("SolTot_p2.png",
plot = SolTot_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("SolTot_p3.png",
plot = SolTot_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("SolTot_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(SolTot_p1, SolTot_p2, SolTot_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 7.96842288970947
Time for this code chunk to
run: 1.45791888237
Time
for this code chunk to run: 0.772003889083862
Time
for this code chunk to run: 0.890688896179199
Time
for this code chunk to run: 0.616358995437622
grid.arrange(iqa_p1, iqa_p2, iqa_p3, ncol = 3)Time
for this code chunk to run: 1.85586714744568
(sum_IQA_p1 <- plan_wide_19902020 %>%
select(CODIGO, IQA, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE),
n =
length(IQA)
)
)## # A tibble: 7 × 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 27.0 35.7 40.9 40.7 46.2 52.2 101
## 2 87398900 27.8 37.9 42.9 43.0 48.0 58.5 101
## 3 87398950 32.8 36.8 41.4 43.2 48.6 61.9 68
## 4 87398980 29.2 35.8 40.4 40.3 44.8 51.9 30
## 5 87405500 24.8 34.9 41.2 40.3 46.9 57.6 97
## 6 87406900 24.7 31.3 37.8 37.4 44.4 49.0 32
## 7 87409900 23.6 31.9 37.1 38.8 46.2 55.4 65
(sum_IQA_p2 <- plan_wide_19902020 %>%
select(CODIGO, IQA, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE),
n =
length(IQA)
)
)## # A tibble: 7 × 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 27.8 34.6 40.0 39.5 43.5 48.7 75
## 2 87398900 28.5 35.1 37.6 38.3 40.6 48.5 77
## 3 87398950 21.1 29.4 32.7 32.8 36.8 44.0 30
## 4 87398980 24.5 35.7 39.4 39.5 43.4 52.1 66
## 5 87405500 19.8 28.7 31.5 31.9 35.7 48.8 78
## 6 87406900 17.1 25.3 29.0 29.5 32.8 44.1 79
## 7 87409900 16.2 20.5 26.1 25.0 29.8 33.1 31
(sum_IQA_p3 <- plan_wide_19902020 %>%
select(CODIGO, IQA, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
# ?as_factor(CODIGO) %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE),
n =
length(IQA),
NAs =
sum(is.na(IQA))
) %>%
mutate(
"%NA" = NAs/n*100
)
)## # A tibble: 7 × 10
## CODIGO min q1 median mean q3 max n NAs `%NA`
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <int> <dbl>
## 1 87398500 40.2 42.5 45.4 44.2 45.5 47.2 34 29 85.3
## 2 87398900 34.1 38.6 41.2 40.2 42.9 44.4 36 32 88.9
## 3 87398950 36.7 39.5 42.4 41.5 44.4 44.6 35 31 88.6
## 4 87398980 40.0 40.0 40.0 40.0 40.0 40.0 28 27 96.4
## 5 87405500 30.8 31.6 32.5 32.5 33.3 34.1 33 31 93.9
## 6 87406900 22.9 24.4 25.9 25.3 26.5 27.2 35 32 91.4
## 7 87409900 24.1 25.1 27.3 26.9 28.2 29.7 37 32 86.5
Time for this code chunk to run: 0.291854858398438
ggsave("iqa.png",
units = c("px"),
width = 4500,
height = 2993,
plot = iqa,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("iqa_p1.png",
plot = iqa_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("iqa_p2.png",
plot = iqa_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("iqa_p3.png",
plot = iqa_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("iqa_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(iqa_p1, iqa_p2, iqa_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 7.98398303985596
parametros_IQA %>%
dplyr::select(
-CODIGO,
-nitro_total) %>%
# group_by(CODIGO) %>%
rename(
CE = Condutividade,
OD = oxigenio_dissolvido,
ST = solidos_totais,
Turb = turbidez,
Temp = temp_agua,
Ptot = fosforo_total,
NAmon = nitro_amon,
NTK = nitro_kjeldahl
) %>%
ggcorr(
method = "complete.obs",
# "pearson",
# "pairwise",
name = "Correlação",
label = TRUE,
label_alpha = TRUE,
digits = 3,
low = "#3B9AB2",
mid = "#EEEEEE",
high = "#F21A00",
# palette = "RdYlBu",
layout.exp = 0,
legend.position = "left",
label_round = 3,
# legend.size = 18,
geom = "tile",
nbreaks = 10,
)+
labs(title = "Correlação entre parâmetros físico-químicos na\nBacia Hidrográfica do rio Gravataí no período 1990-2020")+
theme_linedraw()+
theme(
legend.position = c(0.15, 0.6),
legend.title = element_text(size = 16),
legend.text = element_text(size = 14),
# legend.spacing = unit(element_text(),
# units = 5)
plot.title = element_text(hjust = 0.5,
size = 16)
)correlação-parametros-qualidade-agua-gravataí no período 1990-2020
# Gráfico das correlações entre todos os parâmetros com significância
correl_IQA <- parametros_IQA %>%
dplyr::select(-CODIGO) %>%
ggpairs(title = "Correlação entre parâmetros que compõem o IQA",
axisLabels = "show")
correlacao_pIQA <- parametros_IQA %>%
group_by(CODIGO) %>%
correlation::correlation()
correlacao_pIQA %>%
# glimpse()
filter(
p < 0.001
) %>%
t() %>%
summary()## 87398500 - DBO 87398500 - nitro_kjeldahl 87398500 - nitro_total
## Min. :0.4176 Min. :0.4105 Min. :0.4915
## 1st Qu.:1.0000 1st Qu.:0.7854 1st Qu.:1.0000
## Median :1.0000 Median :1.0000 Median :1.0000
## Mean :0.9552 Mean :0.8634 Mean :0.9609
## 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000
## 87398500 - fosforo_total 87398500 - temp_agua 87398500 - turbidez
## Min. :0.3641 Min. :-0.4765 Min. :0.3641
## 1st Qu.:1.0000 1st Qu.: 1.0000 1st Qu.:1.0000
## Median :1.0000 Median : 1.0000 Median :1.0000
## Mean :0.8668 Mean : 0.8864 Mean :0.9133
## 3rd Qu.:1.0000 3rd Qu.: 1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. : 1.0000 Max. :1.0000
## 87398500 - oxigenio_dissolvido 87398500 - nitro_amon 87398500 - pH
## Min. :-0.4765 Min. :1 Min. :1
## 1st Qu.: 1.0000 1st Qu.:1 1st Qu.:1
## Median : 1.0000 Median :1 Median :1
## Mean : 0.7836 Mean :1 Mean :1
## 3rd Qu.: 1.0000 3rd Qu.:1 3rd Qu.:1
## Max. : 1.0000 Max. :1 Max. :1
## 87398500 - solidos_totais 87398500 - E_coli 87398500 - ANO_COLETA
## Min. :0.4915 Min. :1 Min. :-0.3361
## 1st Qu.:0.8978 1st Qu.:1 1st Qu.: 1.0000
## Median :1.0000 Median :1 Median : 1.0000
## Mean :0.8976 Mean :1 Mean : 0.8972
## 3rd Qu.:1.0000 3rd Qu.:1 3rd Qu.: 1.0000
## Max. :1.0000 Max. :1 Max. : 1.0000
## 87398500 - Condutividade 87398900 - DBO 87398900 - nitro_kjeldahl
## Min. :1 Min. :0.3880 Min. :0.4385
## 1st Qu.:1 1st Qu.:1.0000 1st Qu.:0.9982
## Median :1 Median :1.0000 Median :1.0000
## Mean :1 Mean :0.9529 Mean :0.9000
## 3rd Qu.:1 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1 Max. :1.0000 Max. :1.0000
## 87398900 - nitro_total 87398900 - fosforo_total 87398900 - temp_agua
## Min. :0.4067 Min. :0.3526 Min. :-0.3893
## 1st Qu.:0.9982 1st Qu.:0.5279 1st Qu.: 1.0000
## Median :1.0000 Median :1.0000 Median : 1.0000
## Mean :0.8647 Mean :0.8295 Mean : 0.8931
## 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.: 1.0000
## Max. :1.0000 Max. :1.0000 Max. : 1.0000
## 87398900 - turbidez 87398900 - oxigenio_dissolvido 87398900 - nitro_amon
## Min. :0.4067 Min. :-0.3893 Min. :0.3880
## 1st Qu.:0.9070 1st Qu.: 1.0000 1st Qu.:0.7489
## Median :1.0000 Median : 1.0000 Median :1.0000
## Mean :0.8634 Mean : 0.8931 Mean :0.8447
## 3rd Qu.:1.0000 3rd Qu.: 1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. : 1.0000 Max. :1.0000
## 87398900 - pH 87398900 - solidos_totais 87398900 - E_coli
## Min. :1 Min. :0.4234 Min. :1
## 1st Qu.:1 1st Qu.:0.9070 1st Qu.:1
## Median :1 Median :1.0000 Median :1
## Mean :1 Mean :0.8748 Mean :1
## 3rd Qu.:1 3rd Qu.:1.0000 3rd Qu.:1
## Max. :1 Max. :1.0000 Max. :1
## 87398900 - ANO_COLETA 87398900 - Condutividade 87398950 - DBO
## Min. :0.3526 Min. :1 Min. :1
## 1st Qu.:1.0000 1st Qu.:1 1st Qu.:1
## Median :1.0000 Median :1 Median :1
## Mean :0.9502 Mean :1 Mean :1
## 3rd Qu.:1.0000 3rd Qu.:1 3rd Qu.:1
## Max. :1.0000 Max. :1 Max. :1
## 87398950 - nitro_kjeldahl 87398950 - nitro_total 87398950 - fosforo_total
## Min. :-0.5359 Min. :0.5497 Min. :0.5497
## 1st Qu.: 1.0000 1st Qu.:1.0000 1st Qu.:1.0000
## Median : 1.0000 Median :1.0000 Median :1.0000
## Mean : 0.8593 Mean :0.9647 Mean :0.9307
## 3rd Qu.: 1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. : 1.0000 Max. :1.0000 Max. :1.0000
## 87398950 - temp_agua 87398950 - turbidez 87398950 - oxigenio_dissolvido
## Min. :-0.5945 Min. :0.8455 Min. :-0.5945
## 1st Qu.: 1.0000 1st Qu.:1.0000 1st Qu.: 1.0000
## Median : 1.0000 Median :1.0000 Median : 1.0000
## Mean : 0.8773 Mean :0.9881 Mean : 0.6475
## 3rd Qu.: 1.0000 3rd Qu.:1.0000 3rd Qu.: 1.0000
## Max. : 1.0000 Max. :1.0000 Max. : 1.0000
## 87398950 - nitro_amon 87398950 - pH 87398950 - solidos_totais
## Min. :1 Min. :1 Min. :0.8455
## 1st Qu.:1 1st Qu.:1 1st Qu.:1.0000
## Median :1 Median :1 Median :1.0000
## Mean :1 Mean :1 Mean :0.9881
## 3rd Qu.:1 3rd Qu.:1 3rd Qu.:1.0000
## Max. :1 Max. :1 Max. :1.0000
## 87398950 - E_coli 87398950 - ANO_COLETA 87398950 - Condutividade
## Min. :1 Min. :1 Min. :-0.4515
## 1st Qu.:1 1st Qu.:1 1st Qu.: 1.0000
## Median :1 Median :1 Median : 1.0000
## Mean :1 Mean :1 Mean : 0.8318
## 3rd Qu.:1 3rd Qu.:1 3rd Qu.: 1.0000
## Max. :1 Max. :1 Max. : 1.0000
## 87398980 - DBO 87398980 - nitro_kjeldahl 87398980 - nitro_total
## Min. :1 Min. :1 Min. :1
## 1st Qu.:1 1st Qu.:1 1st Qu.:1
## Median :1 Median :1 Median :1
## Mean :1 Mean :1 Mean :1
## 3rd Qu.:1 3rd Qu.:1 3rd Qu.:1
## Max. :1 Max. :1 Max. :1
## 87398980 - fosforo_total 87398980 - temp_agua 87398980 - turbidez
## Min. :1 Min. :0.5681 Min. :0.5681
## 1st Qu.:1 1st Qu.:1.0000 1st Qu.:1.0000
## Median :1 Median :1.0000 Median :1.0000
## Mean :1 Mean :0.9668 Mean :0.9402
## 3rd Qu.:1 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1 Max. :1.0000 Max. :1.0000
## 87398980 - oxigenio_dissolvido 87398980 - nitro_amon 87398980 - pH
## Min. :1 Min. :1 Min. :1
## 1st Qu.:1 1st Qu.:1 1st Qu.:1
## Median :1 Median :1 Median :1
## Mean :1 Mean :1 Mean :1
## 3rd Qu.:1 3rd Qu.:1 3rd Qu.:1
## Max. :1 Max. :1 Max. :1
## 87398980 - solidos_totais 87398980 - E_coli 87398980 - ANO_COLETA
## Min. :0.6547 Min. :1 Min. :1
## 1st Qu.:1.0000 1st Qu.:1 1st Qu.:1
## Median :1.0000 Median :1 Median :1
## Mean :0.9734 Mean :1 Mean :1
## 3rd Qu.:1.0000 3rd Qu.:1 3rd Qu.:1
## Max. :1.0000 Max. :1 Max. :1
## 87398980 - Condutividade 87405500 - DBO 87405500 - nitro_kjeldahl
## Min. :1 Min. :0.4199 Min. :0.3930
## 1st Qu.:1 1st Qu.:0.5402 1st Qu.:0.6656
## Median :1 Median :1.0000 Median :0.9319
## Mean :1 Mean :0.7900 Mean :0.8206
## 3rd Qu.:1 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1 Max. :1.0000 Max. :1.0000
## 87405500 - nitro_total 87405500 - fosforo_total 87405500 - temp_agua
## Min. :0.5052 Min. :-0.3314 Min. :0.3109
## 1st Qu.:0.6036 1st Qu.: 0.4828 1st Qu.:0.4534
## Median :0.9033 Median : 0.7834 Median :0.5711
## Mean :0.8197 Mean : 0.6601 Mean :0.7138
## 3rd Qu.:1.0000 3rd Qu.: 1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. : 1.0000 Max. :1.0000
## 87405500 - turbidez 87405500 - oxigenio_dissolvido 87405500 - nitro_amon
## Min. :0.3797 Min. :-0.3314 Min. :0.4993
## 1st Qu.:1.0000 1st Qu.: 1.0000 1st Qu.:0.7350
## Median :1.0000 Median : 1.0000 Median :0.9033
## Mean :0.9523 Mean : 0.8976 Mean :0.8353
## 3rd Qu.:1.0000 3rd Qu.: 1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. : 1.0000 Max. :1.0000
## 87405500 - pH 87405500 - solidos_totais 87405500 - E_coli
## Min. :0.3109 Min. :0.3797 Min. :1
## 1st Qu.:0.4284 1st Qu.:0.4477 1st Qu.:1
## Median :0.5052 Median :0.6036 Median :1
## Mean :0.6886 Mean :0.6652 Mean :1
## 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1
## Max. :1.0000 Max. :1.0000 Max. :1
## 87405500 - ANO_COLETA 87405500 - Condutividade 87406900 - DBO
## Min. :1 Min. :0.4527 Min. :0.5144
## 1st Qu.:1 1st Qu.:0.5737 1st Qu.:0.7408
## Median :1 Median :0.8099 Median :1.0000
## Mean :1 Mean :0.7836 Mean :0.8530
## 3rd Qu.:1 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1 Max. :1.0000 Max. :1.0000
## 87406900 - nitro_kjeldahl 87406900 - nitro_total 87406900 - fosforo_total
## Min. :-0.5366 Min. :0.3926 Min. :-0.3894
## 1st Qu.: 0.6958 1st Qu.:0.6754 1st Qu.: 0.6154
## Median : 0.9305 Median :0.8658 Median : 0.7260
## Mean : 0.7673 Mean :0.8084 Mean : 0.6906
## 3rd Qu.: 1.0000 3rd Qu.:1.0000 3rd Qu.: 1.0000
## Max. : 1.0000 Max. :1.0000 Max. : 1.0000
## 87406900 - temp_agua 87406900 - turbidez 87406900 - oxigenio_dissolvido
## Min. :-0.3840 Min. :-0.4238 Min. :-0.5366
## 1st Qu.: 0.4569 1st Qu.: 1.0000 1st Qu.: 1.0000
## Median : 0.6015 Median : 1.0000 Median : 1.0000
## Mean : 0.6624 Mean : 0.8905 Mean : 0.6685
## 3rd Qu.: 1.0000 3rd Qu.: 1.0000 3rd Qu.: 1.0000
## Max. : 1.0000 Max. : 1.0000 Max. : 1.0000
## 87406900 - nitro_amon 87406900 - pH 87406900 - solidos_totais
## Min. :0.4212 Min. :0.3926 Min. :0.4459
## 1st Qu.:0.7397 1st Qu.:1.0000 1st Qu.:0.6187
## Median :0.8658 Median :1.0000 Median :0.6958
## Mean :0.8237 Mean :0.8628 Mean :0.7839
## 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000
## 87406900 - E_coli 87406900 - ANO_COLETA 87406900 - Condutividade
## Min. :1 Min. :-0.4238 Min. :0.4024
## 1st Qu.:1 1st Qu.: 1.0000 1st Qu.:0.6399
## Median :1 Median : 1.0000 Median :0.8068
## Mean :1 Mean : 0.8905 Mean :0.7870
## 3rd Qu.:1 3rd Qu.: 1.0000 3rd Qu.:1.0000
## Max. :1 Max. : 1.0000 Max. :1.0000
## 87409900 - DBO 87409900 - nitro_kjeldahl 87409900 - nitro_total
## Min. :0.5624 Min. :0.6898 Min. :0.5245
## 1st Qu.:1.0000 1st Qu.:0.9999 1st Qu.:0.8314
## Median :1.0000 Median :1.0000 Median :1.0000
## Mean :0.9371 Mean :0.9603 Mean :0.8823
## 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000
## 87409900 - fosforo_total 87409900 - temp_agua 87409900 - turbidez
## Min. :0.4560 Min. :0.4309 Min. :0.4405
## 1st Qu.:0.8175 1st Qu.:1.0000 1st Qu.:1.0000
## Median :0.8565 Median :1.0000 Median :1.0000
## Mean :0.8426 Mean :0.9562 Mean :0.9570
## 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000
## 87409900 - oxigenio_dissolvido 87409900 - nitro_amon 87409900 - pH
## Min. :1 Min. :0.7569 Min. :0.4049
## 1st Qu.:1 1st Qu.:0.8915 1st Qu.:1.0000
## Median :1 Median :1.0000 Median :1.0000
## Mean :1 Mean :0.9482 Mean :0.9542
## 3rd Qu.:1 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1 Max. :1.0000 Max. :1.0000
## 87409900 - solidos_totais 87409900 - E_coli 87409900 - ANO_COLETA
## Min. :0.4405 Min. :0.4528 Min. :0.4528
## 1st Qu.:0.5429 1st Qu.:0.5245 1st Qu.:1.0000
## Median :1.0000 Median :1.0000 Median :1.0000
## Mean :0.8442 Mean :0.8215 Mean :0.9579
## 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000
## 87409900 - Condutividade
## Min. :0.4049
## 1st Qu.:0.4895
## Median :0.7254
## Mean :0.7294
## 3rd Qu.:1.0000
## Max. :1.0000
parametros_IQA %>%
# group_by(CODIGO) %>%
dplyr::select(
nitro_kjeldahl, Condutividade
) %>%
# correlation::cor_test() %>%
plot()correlação-parametros-qualidade-agua-gravataí no período 1990-2020
str(
plot(
correlation::cor_test(
parametros_IQA,
"nitro_kjeldahl",
"Condutividade"
)
)
)## List of 9
## $ data : tibble [1,179 × 14] (S3: tbl_df/tbl/data.frame)
## ..$ CODIGO : chr [1:1179] "87398950" "87398900" "87405500" "87398950" ...
## ..$ pH : num [1:1179] 6.9 6.8 6.6 6.4 6.9 6.7 6.6 6.7 6.3 7.1 ...
## ..$ DBO : num [1:1179] 5 5 11 3 3 2 4 3 4 2 ...
## ..$ E_coli : num [1:1179] 4 40 12.8 10.4 32 16.8 40 6.4 10.4 18.4 ...
## ..$ nitro_amon : num [1:1179] NA NA NA NA NA NA NA NA NA NA ...
## ..$ nitro_kjeldahl : num [1:1179] 1.42 1.61 6.62 0.79 1.45 0.76 1.23 1.37 2.25 1.34 ...
## ..$ nitro_total : num [1:1179] 1.42 1.61 6.62 0.79 1.45 0.76 1.23 1.37 2.25 1.34 ...
## ..$ fosforo_total : num [1:1179] 0.113 0.0883 0.353 0.0908 0.118 0.0326 0.162 0.138 0.217 0.0879 ...
## ..$ temp_agua : num [1:1179] 25 31 31 20 28 16 16 16 18.5 28 ...
## ..$ turbidez : num [1:1179] 20 20 8.5 23 19 17 12 22 17 23 ...
## ..$ solidos_totais : num [1:1179] 121 112 160 93 127 75 80 201 84 123 ...
## ..$ oxigenio_dissolvido: num [1:1179] 6.5 8.7 5.3 7.8 7.6 8.5 7.3 6.9 6.7 6.3 ...
## ..$ Condutividade : num [1:1179] 90 47 147 43 NA 47 70 60.6 72.7 56 ...
## ..$ ANO_COLETA : num [1:1179] 1994 1994 1994 1993 1994 ...
## $ layers :List of 2
## ..$ :Classes 'LayerInstance', 'Layer', 'ggproto', 'gg' <ggproto object: Class LayerInstance, Layer, gg>
## aes_params: list
## compute_aesthetics: function
## compute_geom_1: function
## compute_geom_2: function
## compute_position: function
## compute_statistic: function
## computed_geom_params: NULL
## computed_mapping: NULL
## computed_stat_params: NULL
## constructor: call
## data: waiver
## draw_geom: function
## finish_statistics: function
## geom: <ggproto object: Class GeomSmooth, Geom, gg>
## aesthetics: function
## default_aes: uneval
## draw_group: function
## draw_key: function
## draw_layer: function
## draw_panel: function
## extra_params: na.rm orientation
## handle_na: function
## non_missing_aes:
## optional_aes: ymin ymax
## parameters: function
## rename_size: TRUE
## required_aes: x y
## setup_data: function
## setup_params: function
## use_defaults: function
## super: <ggproto object: Class Geom, gg>
## geom_params: list
## inherit.aes: TRUE
## layer_data: function
## map_statistic: function
## mapping: uneval
## position: <ggproto object: Class PositionIdentity, Position, gg>
## compute_layer: function
## compute_panel: function
## required_aes:
## setup_data: function
## setup_params: function
## super: <ggproto object: Class Position, gg>
## print: function
## setup_layer: function
## show.legend: NA
## stat: <ggproto object: Class StatSmooth, Stat, gg>
## aesthetics: function
## compute_group: function
## compute_layer: function
## compute_panel: function
## default_aes: uneval
## dropped_aes:
## extra_params: na.rm orientation
## finish_layer: function
## non_missing_aes:
## optional_aes:
## parameters: function
## required_aes: x y
## retransform: TRUE
## setup_data: function
## setup_params: function
## super: <ggproto object: Class Stat, gg>
## stat_params: list
## super: <ggproto object: Class Layer, gg>
## ..$ :Classes 'LayerInstance', 'Layer', 'ggproto', 'gg' <ggproto object: Class LayerInstance, Layer, gg>
## aes_params: list
## compute_aesthetics: function
## compute_geom_1: function
## compute_geom_2: function
## compute_position: function
## compute_statistic: function
## computed_geom_params: NULL
## computed_mapping: NULL
## computed_stat_params: NULL
## constructor: call
## data: tbl_df, tbl, data.frame
## draw_geom: function
## finish_statistics: function
## geom: <ggproto object: Class GeomPoint, Geom, gg>
## aesthetics: function
## default_aes: uneval
## draw_group: function
## draw_key: function
## draw_layer: function
## draw_panel: function
## extra_params: na.rm
## handle_na: function
## non_missing_aes: size shape colour
## optional_aes:
## parameters: function
## rename_size: FALSE
## required_aes: x y
## setup_data: function
## setup_params: function
## use_defaults: function
## super: <ggproto object: Class Geom, gg>
## geom_params: list
## inherit.aes: TRUE
## layer_data: function
## map_statistic: function
## mapping: uneval
## position: <ggproto object: Class PositionIdentity, Position, gg>
## compute_layer: function
## compute_panel: function
## required_aes:
## setup_data: function
## setup_params: function
## super: <ggproto object: Class Position, gg>
## print: function
## setup_layer: function
## show.legend: NA
## stat: <ggproto object: Class StatIdentity, Stat, gg>
## aesthetics: function
## compute_group: function
## compute_layer: function
## compute_panel: function
## default_aes: uneval
## dropped_aes:
## extra_params: na.rm
## finish_layer: function
## non_missing_aes:
## optional_aes:
## parameters: function
## required_aes:
## retransform: TRUE
## setup_data: function
## setup_params: function
## super: <ggproto object: Class Stat, gg>
## stat_params: list
## super: <ggproto object: Class Layer, gg>
## $ scales :Classes 'ScalesList', 'ggproto', 'gg' <ggproto object: Class ScalesList, gg>
## add: function
## clone: function
## find: function
## get_scales: function
## has_scale: function
## input: function
## n: function
## non_position_scales: function
## scales: list
## super: <ggproto object: Class ScalesList, gg>
## $ mapping : Named list()
## ..- attr(*, "class")= chr "uneval"
## $ theme : list()
## $ coordinates:Classes 'CoordCartesian', 'Coord', 'ggproto', 'gg' <ggproto object: Class CoordCartesian, Coord, gg>
## aspect: function
## backtransform_range: function
## clip: on
## default: TRUE
## distance: function
## expand: TRUE
## is_free: function
## is_linear: function
## labels: function
## limits: list
## modify_scales: function
## range: function
## render_axis_h: function
## render_axis_v: function
## render_bg: function
## render_fg: function
## setup_data: function
## setup_layout: function
## setup_panel_guides: function
## setup_panel_params: function
## setup_params: function
## train_panel_guides: function
## transform: function
## super: <ggproto object: Class CoordCartesian, Coord, gg>
## $ facet :Classes 'FacetNull', 'Facet', 'ggproto', 'gg' <ggproto object: Class FacetNull, Facet, gg>
## compute_layout: function
## draw_back: function
## draw_front: function
## draw_labels: function
## draw_panels: function
## finish_data: function
## init_scales: function
## map_data: function
## params: list
## setup_data: function
## setup_params: function
## shrink: TRUE
## train_scales: function
## vars: function
## super: <ggproto object: Class FacetNull, Facet, gg>
## $ plot_env :<environment: 0x000002a8deaab9d0>
## $ labels :List of 4
## ..$ title : NULL
## ..$ subtitle: chr "r = 0.83, 95% CI [0.81, 0.86], t(605) = 36.90, p < .001"
## ..$ x : chr "nitro_kjeldahl"
## ..$ y : chr "Condutividade"
## - attr(*, "class")= chr [1:2] "gg" "ggplot"
Time for this code chunk to run: 5.23260879516602
(cond_elet <- ggplot(plan_wide_19902020,
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Condutividade elétrica no período 1990-2020",
x="Estação",
y="µmhos/cm")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for
this code chunk to run: 2.45411801338196
(cond_elet_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Condutividade elétrica no período 1990-2000",
x="Estação",
y="µmhos/cm")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 1.77619791030884
(cond_elet_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Condutividade elétrica no período 2000-2010",
x="Estação",
y="µmhos/cm")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 1.65006995201111
(cond_elet_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Condutividade elétrica no período 2010-2020",
x="Estação",
y="µmhos/cm")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 1.22569513320923
grid.arrange(cond_elet_p1, cond_elet_p2, cond_elet_p3, ncol = 3)Time
for this code chunk to run: 2.51137900352478
(sum_cond_elet_p1 <- plan_wide_19902020 %>%
select(CODIGO, Condutividade, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Condutividade,
na.rm = TRUE),
q1 =
quantile(Condutividade, 0.25,
na.rm = TRUE),
median =
median(Condutividade,
na.rm = TRUE),
mean =
mean(Condutividade,
na.rm= TRUE),
q3 =
quantile(Condutividade, 0.75,
na.rm = TRUE),
max =
max(Condutividade,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 9.4 51.1 67 75.1 83.2 340
## 2 87398900 10 41.5 51 55.3 64.2 160
## 3 87398950 9 41.5 51.5 60.1 69.5 160
## 4 87398980 11.3 42.4 52.0 53.0 67.0 83.8
## 5 87405500 25 68.7 88.2 130. 170 560
## 6 87406900 52 88.4 133. 193. 256. 576
## 7 87409900 29 80 110. 134. 168. 460
(sum_cond_elet_p2 <- plan_wide_19902020 %>%
select(CODIGO, Condutividade, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Condutividade,
na.rm = TRUE),
q1 =
quantile(Condutividade, 0.25,
na.rm = TRUE),
median =
median(Condutividade,
na.rm = TRUE),
mean =
mean(Condutividade,
na.rm= TRUE),
q3 =
quantile(Condutividade, 0.75,
na.rm = TRUE),
max =
max(Condutividade,
na.rm = TRUE))
)## # A tibble: 7 × 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 11.9 67.0 82.6 84.8 102. 164.
## 2 87398900 11 44.4 52.3 57.1 72.6 136.
## 3 87398950 39.8 58.4 76 82.3 98.3 160
## 4 87398980 9.4 42.4 49.7 51.5 62 114.
## 5 87405500 17 77.5 107 142. 171. 679
## 6 87406900 23.1 85.6 124. 164. 199. 619
## 7 87409900 56.1 114. 177 200. 242 454
(sum_cond_elet_p3 <- plan_wide_19902020 %>%
select(CODIGO, Condutividade, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Condutividade,
na.rm = TRUE),
q1 =
quantile(Condutividade, 0.25,
na.rm = TRUE),
median =
median(Condutividade,
na.rm = TRUE),
mean =
mean(Condutividade,
na.rm= TRUE),
q3 =
quantile(Condutividade, 0.75,
na.rm = TRUE),
max =
max(Condutividade,
na.rm = TRUE),
n =
length(Condutividade))
)## # A tibble: 7 × 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 0.01 68.5 80.2 80.4 99.5 125. 34
## 2 87398900 39.7 53.4 58.3 61.1 65.5 103 36
## 3 87398950 40.9 64.7 70.1 76.1 82.5 195. 35
## 4 87398980 43.2 51.7 54.0 56.3 61.0 78.9 28
## 5 87405500 47 85.8 121. 146. 209. 286 33
## 6 87406900 62.7 95.9 142. 163. 216. 354. 35
## 7 87409900 65.7 121. 159. 179. 245. 498. 37
# plan_wide_19902020 %>%
# select(CODIGO, IQA) %>%
# group_by(CODIGO) %>%
# summarize(
# min =
# min(IQA,
# na.rm = TRUE),
# q1 =
# quantile(IQA, 0.25,
# na.rm = TRUE),
# median =
# median(IQA,
# na.rm = TRUE),
# mean =
# mean(IQA,
# na.rm= TRUE),
# q3 =
# quantile(IQA, 0.75,
# na.rm = TRUE),
# max =
# max(IQA,
# na.rm = TRUE))Time for this code chunk to run: 0.299726963043213
ggsave("cond_elet.png",
units = c("px"),
width = 4500,
height = 2993,
plot = cond_elet,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("cond_elet_p1.png",
plot = cond_elet_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("cond_elet_p2.png",
plot = cond_elet_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("cond_elet_p3.png",
plot = cond_elet_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("cond_elet_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(cond_elet_p1, cond_elet_p2, cond_elet_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 8.21060585975647
10.8
Os resultados apontam que para o parâmetro OD
(boxplot_example <- data.frame(
PM = c("PM1"),
# letras = letters[seq( from = 1, to = 1 )],
Stat1 = rnorm(100,
mean=5,
sd=3)
) %>%
ggplot(
aes(
x = PM,
y = Stat1,
)
)+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = -Inf, ymax = 2,
alpha = 1,
fill = "#ac5079")+ #>pior classe
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 2, ymax = 4,
alpha = 1,
fill = "#eb5661")+ #classe 4
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 4, ymax = 5,
alpha = 1,
fill = "#fcf7ab")+ #classe 3
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 5, ymax = 6,
alpha = 1,
fill = "#70c18c")+ #classe 2
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin= 6, ymax = Inf,
alpha = 1,
fill = "#8dcdeb")+ #classe 1
stat_summary(
fun.data = f,
geom = 'errorbar',
width = 0.15,
position = position_dodge(width = 0.65),
)+
stat_summary(
fun.data = f,
geom = "boxplot",
width = 0.40,
fill = '#F8F8FF',
color = "black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
)+
labs(
title = "Elementos do *boxplot*",
x= NULL,
y= NULL
)+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(
expand = expansion(mult = c(0,0)),
n.breaks = 8,
limits = c(-0.3,14)
)+
theme_grafs()+
theme(
plot.title =
element_markdown(
hjust = 0.5,
color = "black",
size = 19),
)
)## Warning: Removed 3 rows containing non-finite values (`stat_summary()`).
## Removed 3 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 3 rows containing missing values.
Time
for this code chunk to run: 0.488339900970459
set.seed(2021)
data <- tibble(
grupo = factor(
c(rep(
"Grupo 1", 100),
rep("Grupo 2", 250),
rep("Grupo 3", 25)
)
),
valor = c(seq(0, 20, length.out = 100),
c(rep(0, 5),
rnorm(30, 2, .1),
rnorm(90, 5.4, .1),
rnorm(90, 14.6, .1),
rnorm(30, 18, .1),
rep(20, 5)
),
rep(seq(0, 20, length.out = 5), 5))
) %>%
rowwise() %>%
mutate(
valor = if_else(
grupo == "Grupo 2", valor + rnorm(1, 0, .4),
valor
)
)
## function to return median and labels
n_fun <- function(x){
return(
data.frame(
y = median(x) - 1.25,
label = paste0(
"n = ",length(x)
)
)
)
}Time for this code chunk to run: 0.0371270179748535
(tukey_n_boxplot <- ggplot(data,
aes(x = grupo,
y = valor)
)+
stat_boxplot(geom = 'errorbar',
width = 0.15,
position = position_dodge(width = 0.65))+
geom_boxplot(fill = "grey92",
width = 0.40,
position = position_dodge(width = 0.65))+
## use summary function to add text labels
stat_summary(
geom = "text",
fun.data = n_fun,
family = "Oswald",
size = 5
)+
labs(
title = "Tukey *boxplot*",
x= NULL,
# y="mg/L"
)+
# theme_grafs()+
theme_bw()+
theme(
axis.text.y = element_text(
angle = 90,
# size=15,
# face=2
),
plot.title =
element_markdown(
hjust = 0.5,
color = "black",
size = 19)
)
)## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
(tukey_boxplot <- ggplot(data, aes(x = grupo,
y = valor)) +
stat_boxplot(geom = 'errorbar',
width = 0.15,
position = position_dodge(width = 0.65))+
geom_boxplot(fill = "grey92",
width = 0.40,
position = position_dodge(width = 0.65)) +
## use either geom_point() or geom_jitter()
geom_point(
## draw bigger points
size = 2,
## add some transparency
alpha = .25,
## add some jittering
position = position_jitter(
## control randomness and range of jitter
seed = 1, width = .2
)
)+
theme_bw()+
labs(
title = "Tukey *boxplot*",
x= NULL,
# y="mg/L"
)+
# theme_grafs()+
theme_bw()+
theme(
axis.text.y = element_text(
angle = 90,
# size=15,
# face=2
),
plot.title =
element_markdown(
hjust = 0.5,
color = "black",
size = 19)
))Time
for this code chunk to run: 0.789608955383301
data %>%
group_by(grupo) %>%
summarize(
min = min(valor),
P20 = quantile(valor, 0.20),
q1 = quantile(valor, 0.25),
mediana = median(valor),
q3 = quantile(valor, 0.75),
P80 = quantile(valor, 0.80),
max = max(valor)
) %>%
t() %>%
row_to_names(row_number = 1)## Grupo 1 Grupo 2 Grupo 3
## min " 0.0000000" "-0.6345142" " 0.0000000"
## P20 "4.000000" "5.057189" "4.000000"
## q1 "5.000000" "5.245691" "5.000000"
## mediana "10.00000" "10.01593" "10.00000"
## q3 "15.00000" "14.81205" "15.00000"
## P80 "16.00000" "15.04351" "16.00000"
## max "20.0000" "20.3882" "20.0000"
(box_percentile_plot <- ggplot(data,
aes(x = grupo, y = valor)
) +
stat_summary(
fun.data = f,
geom = 'errorbar',
width = 0.15,
position = position_dodge(width = 0.65),
)+
stat_summary(
fun.data = f,
geom = "boxplot",
width = 0.40,
fill = 'grey92',
color = "black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
)+
# geom_boxplot(fill = "grey92") +
## use either geom_point() or geom_jitter()
geom_point(
## draw bigger points
size = 2,
## add some transparency
alpha = .25,
## add some jittering
position = position_jitter(
## control randomness and range of jitter
seed = 1, width = .2
)
)+
labs(
title = "*Box Percentile-Plot*",
x= NULL,
# y="mg/L"
)+
# theme_grafs()+
theme_bw()+
theme(
axis.text.y = element_text(
angle = 90,
# size = 15,
# face = 2
),
plot.title =
element_markdown(
hjust = 0.5,
color = "black",
size = 19)
)
)grid.arrange(
tukey_boxplot, box_percentile_plot,
ncol = 2
)fig_tukey_garrett <- plot_grid(tukey_boxplot, box_percentile_plot,
labels = "AUTO")Time for this code chunk to run: 1.51265001296997
ggsave(
filename = "tukey_n_boxplot.png",
plot = tukey_n_boxplot,
units = c("px"),
width = 4500,
height = 2993,
path = "./graficos",
dpi = 300,
# type = "cairo"
)## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
ggsave(
filename = "tukey_boxplot.png",
plot = tukey_boxplot,
units = c("px"),
width = 4500,
height = 2993,
path = "./graficos",
dpi = 300,
# type = "cairo"
)
ggsave(
filename = "box_percentile_plot.png",
plot = box_percentile_plot,
units = c("px"),
width = 4500,
height = 2993,
path = "./graficos",
dpi = 300,
# type = "cairo"
)
ggsave(
filename = "fig_tukey_garrett.png",
plot = fig_tukey_garrett,
units = c("px"),
width = 4500,
height = 2993,
path = "./graficos",
dpi = 300,
# type = "cairo"
)Time for this code chunk to run: 2.96358919143677